import { createWebHistory, createRouter } from "vue-router";

const routes = [
  {
    path: "/login",
    name: "Login",
    component: () => import("../views/Login.vue"),
  },
  {
    path: "/",
    name: "index",
    component: () => import("../Layout/index.vue"),
    redirect: "/home",
    children: [
      {
        path: "/home",
        name: "Home",
        component: () => import("../views/Home.vue"),
      },
      {
        path: "/type",
        name: "Type",
        component: () => import("../views/type.vue"),
      },
      {
        path: "/me",
        name: "Me",
        component: () => import("../views/me.vue"),
      },
      // 截取屏幕的一部分生成图片
      {
        path: "/snipasteToPng",
        name: "SnipasteToPng",
        component: () => import("../views/功能/截取屏幕的一部分生成图片.vue"),
      },
      // 图片拖拉拽
      {
        path: "/dragPic",
        name: "DragPic",
        component: () => import("../views/功能/图片的拖拉拽.vue"),
      },
      // 可视化大屏适配--scale
      {
        path: "/screen",
        name: "Screen",
        component: () => import("../views/框架/大屏适配.vue"),
      },
      // 文件预览与下载
      {
        path: "/filePreview",
        name: "FilePreview",
        component: () => import("../views/功能/文件的预览与下载.vue"),
      },
      // 文字片段截取
      {
        path: "/reText",
        name: "ReText",
        component: () => import("../views/框架/文字提示.vue"),
      },
      // 水印
      {
        path: "/qrcode",
        name: "QrCode",
        component: () => import("../views/框架/二维码.vue"),
      },
      // 动画交互
      {
        path: "/interaction",
        name: "Interaction",
        component: () => import("../views/扩展/动画交互.vue"),
      },
      // 聊天输入框
      {
        path: "/chat",
        name: "Chat",
        component: () => import("../views/框架/聊天输入框.vue"),
      },
      // 常用函数
      {
        path: "/commonUtils",
        name: "CommonUtils",
        component: () => import("../views/函数/常用函数.vue"),
      },
      // 禁止调试
      {
        path: "/banDebugging",
        name: "banDebugging",
        component: () => import("../views/扩展/禁止别人调试.vue"),
      },
      // TYZ 测试首页
      {
        path: "/TyzHomeView",
        name: "TyzHomeView",
        component: () => import("../views/扩展/首页-Tyz.vue"),
      },
      // 合并行列
      {
        path: "/mergeRowOrColumn",
        name: "MergeRowOrColumn",
        component: () => import("../views/函数/合并相同行列.vue"),
      },
      {
        path: "/encrypt",
        name: "Encrypt",
        component: () => import("../views/函数/加密解密.vue"),
      },
      {
        path: "/dragTable",
        name: "DragTable",
        component: () => import("../views/功能/表格拖拽.vue"),
      },
      {
        path: "/virtualList",
        name: "VirtualList",
        component: () => import("../views/性能/虚拟列表.vue"),
      },
      {
        path: "/numberRain",
        name: "NumberRain",
        component: () => import("../views/扩展/数字雨.vue"),
      },
      {
        path: '/i18n',
        name: 'I18n',
        component: () => import('../views/框架/国际化.vue')
      },
      {
        path: '/rich',
        name: 'Rich',
        component: () => import('../views/框架/富文本.vue')
      },
      {
        path: '/imgPreview',
        name: 'ImgPreview',
        component: () => import('../views/功能/图片预览.vue')
      },
      {
        path: '/waterfall',
        name: 'Waterfall',
        component: () => import('../views/框架/瀑布流.vue')
      },
      {
        path: '/:pathMatch(.*)*',
        name: "404",
        component: () => import("../views/404.vue"),
      }
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

router.beforeEach((to, from, next) => {
  document.title = 'IKun | ' + to.name
  next();
});

export default router;
